# Maintainer: Sarah Ottinger <schalaalexiazeal@gmail.com>

_realname=google-auth
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=2.15.0
pkgrel=1
pkgdesc='Google Authentication Library (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url="https://googleapis.dev/python/google-auth/latest/"
license=('Apache')
depends=("${MINGW_PACKAGE_PREFIX}-ca-certificates"
         "${MINGW_PACKAGE_PREFIX}-python-cachetools"
         "${MINGW_PACKAGE_PREFIX}-python-pyasn1-modules"
         "${MINGW_PACKAGE_PREFIX}-python-rsa"
         "${MINGW_PACKAGE_PREFIX}-python-six")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-flask"
              "${MINGW_PACKAGE_PREFIX}-python-freezegun"
              "${MINGW_PACKAGE_PREFIX}-python-mock"
              "${MINGW_PACKAGE_PREFIX}-python-oauth2client"
              "${MINGW_PACKAGE_PREFIX}-python-pyopenssl"
              "${MINGW_PACKAGE_PREFIX}-python-pytest"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-cov"
              "${MINGW_PACKAGE_PREFIX}-python-pytest-localserver"
              "${MINGW_PACKAGE_PREFIX}-python-pyu2f"
              "${MINGW_PACKAGE_PREFIX}-python-requests"
              "${MINGW_PACKAGE_PREFIX}-python-urllib3"
              "${MINGW_PACKAGE_PREFIX}-python-cryptography"
              "${MINGW_PACKAGE_PREFIX}-python-responses")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('!emptydirs')
source=("${_realname}-$pkgver.tar.gz::https://github.com/googleapis/google-auth-library-python/archive/v$pkgver.tar.gz")
sha256sums=('8f280c0d0d42d61ad17111e7042b360a96b1d2723f277855fe1385fdd013ac72')

prepare() {
  cd "$srcdir"
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-library-python-${pkgver}" "python-build-${MSYSTEM}"
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python -m pytest tests || warning "Tests failed"
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build
  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
